package chapter07;
public class Homework04 {

    //��дһ��main����
    public static void main(String[] args) {
        int[] oldArr = {10, 30, 50};
        A03 a03 = new A03();
        int[] newArr = a03.copyArr(oldArr);//用数组的形式接受
        //遍历newArr,验证
        System.out.println("==返回newArr元素情况==");
        for(int i = 0; i < newArr.length; i++) {
            System.out.print(newArr[i] + "\t");
        }
    }
}

/*
/*
编写类AO3，实现数组的复制功能copyArr， 输入旧数组，返回一个新数组，元秦和旧数组—样*Ⅰ

 */
class A03 {
    public int[] copyArr(int[] oldArr) {
        //在堆中，创建一个长度为oldArr.length数组
        int[] newArr = new int[oldArr.length];
        //逼历oldArr,将元素拷贝到newArr
        for(int i = 0; i < oldArr.length; i++) {
            newArr[i] = oldArr[i];
        }

        return newArr;

    }
}
